﻿<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
		<meta name="apple-mobile-web-app-title" content="思路广惠">
		<title>订单</title>

		<meta content="telephone=no" name="format-detection" />

		<link rel="stylesheet" type="text/css" href="../../src/css/base.css?1.0" />
		
	</head>

	<body class="body-bg">
		<header class="header">
			<a href="javascript: history.go(-1)" class="head-le"><i class="iconfont icon-fanhui i2m"></i></a>
			<div class="header-txt">现金订单</div>
		</header>
		<section>
			<ul id="chooseh" class="flexs-bw pad1rem s12m bg-fff">
				
			</ul>
			<ul class="order-all">

			</ul>

		</section>
		<script type="text/html" class="choosehs">
			<li class="huef36" data-type="9">全部</li>
			<li data-type="10">待付款</li>
			<li data-type="11">待发货</li>
			<li data-type="12">待收货</li>
			<li data-type="13">已签收</li>
		</script>
	
		<script type="text/html" class="choosehs">
			<li class="huef36" data-type="9">全部</li>
			<li data-type="10">已预约</li>
			<li data-type="13">已签收</li>
		</script>
		
		<script type="text/html" class="choosehs">
			<li class="huef36" data-type="0">可申请</li>
			<li data-type="31">待确认</li>
			<li data-type="32">已返现</li>
		</script>
		<script type="text/html" class="order-all">
			{{# if(d.PageData.length == 0){ }}
				<div style="margin-top: 50%; text-align: center;">无此类订单</div>
			{{# } }} 
			
			{{# for(var i = 0; i < d.PageData.length; i++){ }} 
				<li class="top1rem bg-fff">
					<div class="pad1rem flexs-bw setup-btm">
						<a class="s12m col3	" href="../home/homestore.html?{{d.PageData[i].Business_ID}}">{{d.PageData[i].Business_Name}}</a>
						<span class="s12m huef36">
		                    {{# if(d.PageData[i].Order_Mark == 10){ }}
		                    待付款
		                    {{# }else if(d.PageData[i].Order_Mark == 11){ }}
		                    待发货
		                    {{# }else if(d.PageData[i].Order_Mark == 12){ }}
		                    待收货
		                    {{# }else if(d.PageData[i].Order_Mark == 13){ }}
		                    已签收
		                    {{# }else if(d.PageData[i].Order_Mark == 19){ }}
		                    已取消
		                    {{# } }}
	               </span>
					</div>
				{{# for(var j = 0; j < d.PageData[i].OrderList.length; j++){ }} 
					<a class="blocks padi5m s11m" href="/order/orderDetails?{{d.PageData[i].Order_ID}}">
				 		<div class="flexs setup-btm">
							<figure class="line-ht padi5m"> 
								<img class="vw25" src={{d.img}}{{d.PageData[i].OrderList[j].Image_Url}} /> 
							</figure>
							<div class="flex1 flexs-cs padi5m">
								<p class="col3">
									{{d.PageData[i].OrderList[j].Product_Name}}
								</p>
								<p>{{d.PageData[i].OrderList[j].ProductSuk_Name}}</p>
								<p class="flexs-bw">
									<span class="huef36">￥{{d.PageData[i].OrderList[j].ProductSuk_PriceCash}}</span> {{# if(d.PageData[i].Order_BuyType == "1" ){ }} + 积分 {{d.PageData[i].OrderList[j].ProductSuk_PricePoints}} {{# } }}
									<span >×{{d.PageData[i].OrderList[j].OrderList_Amount}}</span>
								</p>
							</div>
						 </div>
					</a>
				{{# } }}
				 
						<div class="flexs-bw pad1rem s11m">
							<p>
								<span >积分</span> 
								<span>返还积分：</span> 
								<span class="huef36">{{d.PageData[i].Order_BuyTotalGiven}}</span>
							</p>
							<strong>共{{d.PageData[i].OrderList.length}}件商品</strong>
						</div>
						<p align="right" class="setup-u pad1rem s11m">
							 --- 合计:<span class="huef36">￥{{d.PageData[i].Order_BuyTotalCash}}</span> {{# if(d.PageData[i].Order_BuyType == "1" ){ }} + 积分 {{d.PageData[i].Order_BuyTotalPoints}} {{# } }}
						</p>
						<p align="right" class="pad1rem s11m">
							{{# if(d.PageData[i].Order_Mark == 10){ }}
							<button >取消订单</button>
							<button >立即付款</button> 
							{{# }else if(d.PageData[i].Order_Mark == 11){ }}
							<button >取消订单</button> 
							{{# }else if(d.PageData[i].Order_Mark == 12){ }}
							<button >查看物流</button>
							<button>确认签收</button>
						
						{{# }else if(d.PageData[i].Order_Mark == 13){ }}
						<button>查看物流</button>
						<button>申请退货</button>
						<button>申请返现</button> {{# }else if(d.PageData[i].Order_Mark == 19){ }}
						<button>删除订单</button> {{# } }}
						</p>
				 
					</li>

					{{# } }}
		</script>
		<script src="http://apps.bdimg.com/libs/laytpl.js/1.1/laytpl.js"></script>
		<script src="//cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
		<script src="//cdn.bootcss.com/layer/3.0.1/mobile/layer.js"></script>
		<script src="../../src/js/all.js" type="text/javascript" charset="utf-8"></script>
		<script>
			var flag = silks.getByVal("flag");
			// 现金订单
			var getOrders = function(type, url, data, before, callback) {
				$.ajax({
					type: type,
					url: urls + url,
					data: data,
					beforeSend: before,
					success: callback
				});
			};
			$(function() {
				// 页面初始化执行所有状态请求
				var getMarks = function(mark, type, url) {
					getOrders(type, url, {
						Mode: "members",
						MembersID: MembersID,
						PageIndex: 0,
						Mark: mark,
						AppID: AppID,
						Token: Token
					}, function() {
						$(".order-all:first").html("<div style='text-align: center; margin-top: 50%;'>正在加载中</div>");
					}, function(res) {
						console.log(res)
						if(res.Return_ID == 0) {
							var res = res.Return_Data;
							res.img = imgurlbig; // 添加图片总路径

							laytpl($(".order-all:last").html()).render(res, function(html) {
								$(".order-all:first").html(html);
							});

						} else if(res.Return_ID == 904) {
							window.location.replace("../login/Index")
						}
					});
				};
				if(flag == 0) {
					getMarks(9, "post", "/WorkOrder/GetCashOrder"); // 初始化执行
					$("#chooseh").html($(".choosehs").eq(0).html())
				}
				if(flag == 1) {
					getMarks(9, "post", "/WorkOrder/GetPointOrder"); // 初始化执行
					$("#chooseh").html($(".choosehs").eq(0).html())
				}
				if(flag == 2) {
					getMarks(9, "post", "/WorkOrder/GetOffLineOrder"); // 初始化执行
					$("#chooseh").html($(".choosehs").eq(1).html())
				}
				if(flag == 3) {
					getOrders("get", "/WorkOrder/GetGivenApplyOrder", {
						MembersID: MembersID,
						PageIndex: 0,
						AppID: AppID,
						Token: Token
					}, function() {
						$(".order-all:first").html("<div style='text-align: center; margin-top: 50%;'>正在加载中</div>");
					}, function(res) {
						console.log(res)
						if(res.Return_ID == 0) {
							var res = res.Return_Data;
							res.img = imgurlbig; // 添加图片总路径

							laytpl($(".order-all:last").html()).render(res, function(html) {
								$(".order-all:first").html(html);
							});

						} else if(res.Return_ID == 904) {
							window.location.replace("../login/index.html")
						}
					});

					$("#chooseh").html($(".choosehs").eq(2).html())
				}
				if(flag == 4) {
					getMarks(9, "post", "/WorkOrder/GetOrderBack"); // 初始化执行
					$("#chooseh").html($(".choosehs").eq(0).html())
				}

				// 点击头部状态查询
				$("#chooseh li").click(function() {
					$(this).addClass("huef36").siblings().removeClass("huef36");
					if(flag == 0) {
						getMarks($(this).attr("data-type"), "post", "/WorkOrder/GetCashOrder");
					}
					if(flag == 1) {
						getMarks($(this).attr("data-type"), "post", "/WorkOrder/GetPointOrder");
					}
					if(flag == 2) {
						getMarks($(this).attr("data-type"), "post", "/WorkOrder/GetOffLineOrder");
					}

					if(flag == 3) {
						if($(this).attr("data-type") == 0) {
							getOrders("get", "/WorkOrder/GetGivenApplyOrder", {
								MembersID: MembersID,
								PageIndex: 0,
								AppID: AppID,
								Token: Token
							}, function() {
								$(".order-all:first").html("<div style='text-align: center; margin-top: 50%;'>正在加载中</div>");
							}, function(res) {
								console.log(res)
								if(res.Return_ID == 0) {
									var res = res.Return_Data;
									res.img = imgurlbig; // 添加图片总路径

									laytpl($(".order-all:last").html()).render(res, function(html) {
										$(".order-all:first").html(html);
									});

								} else if(res.Return_ID == 904) {
									window.location.replace("../login/Index")
								}
							});

						} else if($(this).attr("data-type") == 31) {
							getMarks($(this).attr("data-type"), "post", "/WorkOrder/GetWaitGivenOrder");
						} else if($(this).attr("data-type") == 32) {
							getMarks($(this).attr("data-type"), "post", "/WorkOrder/GetGivenOrder");
						}

					}

					if(flag == 4) {
						getMarks($(this).attr("data-type"), "post", "/WorkOrder/GetOrderBack");
					}
				});

			});
		</script>
	</body>

</html>